import java.util.Arrays;

public class Solution1798 {
    public int getMaximumConsecutive(int[] coins) {
        Arrays.sort(coins);
        int t=0,ans=0;
        while (t<coins.length && coins[t]==1){
            t++;
            ans++;
        }
        while (t<coins.length){
            if (coins[t]>ans+1){
                break;
            }else {
                ans+=coins[t];
                t++;
            }
        }
        return ans+1;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1798().getMaximumConsecutive(new int[]{1,4,10,3,1}));
    }
}
